package com.study.aliyun.datawork;

import com.alibaba.fastjson.JSONObject;
import com.study.util.DateUtil;

import java.util.Date;

/**
 * @version V1.0
 * @title: Main
 * @description: ${DESCRIPTION}
 * @author: wanghuilong
 * @date: 2020-06-10 18:01
 * @copyright: http://fingo.com.my/
 */
public class Main {

    static String param =
            "`product_id`                    BIGINT COMMENT '商品ID',\n" +
                    "`cate_one_id`                   BIGINT COMMENT '一级类目Id',\n" +
                    "`cate_one_name`                 STRING COMMENT '一级类目名称',\n" +
                    "`cate_two_id`                   BIGINT COMMENT '二级类目Id',\n" +
                    "`cate_two_name`                 STRING COMMENT '二级类目名称',\n" +
                    "`cate_three_id`                 BIGINT COMMENT '三级类目Id',\n" +
                    "`cate_three_name`               STRING COMMENT '三级类目名称',\n" +
                    "`shelving_method`               BIGINT COMMENT '上架方式',\n" +
                    "`shelving_time`                 DATE COMMENT '创建时间'";

    static String param2 = "";

    public static void main(String[] args) {
        JSONObject jsonObject = JSONObject.parseObject("{\"startDate\":\"2019-10-21\",\"endDate\":\"2020-08-06\",\"count\":30}");
        Date startDate = jsonObject.getDate("startDate");
        Date endDate = jsonObject.getDate("endDate");
        Integer count = 3;
        if (jsonObject.containsKey("count")) {
            count = jsonObject.getInteger("count");
        }
        Long time = endDate.getTime() - startDate.getTime();
        Long n = (time / 86400000) + (time % 86400000 > 0 ? 1 : 0);

        long time1 = startDate.getTime();
        System.out.println("time1：" + time1);
        for (long i = 1; i <= n; i++) {
            Date date1 = new Date(time1 + (i - 1) * 86400000);
            Date date2 = new Date(time1 + i * 86400000);
            try {
                System.out.println("updateChatMsgTask i:" + i + " date1:" + DateUtil.formateDate(date1) + " date2:" + DateUtil.formateDate(date2));
            } catch (Exception e) {

            }
        }
    }

    private static void out1() {
        StringBuilder stringBuilder = new StringBuilder();
        String[] split = param.split("\n");
        for (int i = 0; i < split.length; i++) {
            String str = split[i].trim();
            String ps[] = str.split(" ");
            stringBuilder.append("").append(ps[0].replaceAll("`", "").replaceAll(",", "")).append(",\n");
        }
        System.out.println(stringBuilder);
    }

}
